<?php

/**
 * 微信模块
 */


namespace frontend\modules\wechat;
use common\models\wechat\WechatAccounts;
use common\models\wechat\WechatPaySetting;
use Yii;

class Module extends \yii\base\Module
{

    public $controllerNamespace = 'frontend\modules\wechat\controllers';


    public function init()
    {
        $model = WechatAccounts::findOne(WechatAccounts::WID);
        //设置参数
        Yii::$app->params['WECHAT']['app_id'] = $model->key;
        Yii::$app->params['WECHAT']['secret'] = $model->secret;
        Yii::$app->params['WECHAT']['token'] = $model->token;
        Yii::$app->params['WECHAT']['aes_key'] = $model->encodingaeskey;

        $payment = WechatPaySetting::findOne(['wid'=>$model->id]);
        Yii::$app->params['WECHAT']['payment'] = [
            'merchant_id' => $payment->mchid,
            'key' => $payment->apisecret,
        ];

        parent::init();
    }


}


